package com.infitecs.eyas.boiler.service.impl;

import com.infitecs.eyas.boiler.dao.AirGasParameterDao;
import com.infitecs.eyas.boiler.dao.EfficiencyDao;
import com.infitecs.eyas.boiler.model.AirGasParameter;
import com.infitecs.eyas.boiler.model.Efficiency;
import com.infitecs.eyas.boiler.service.EfficiencyService;
import com.infitecs.eyas.combustion.dao.BurnDao;
import com.infitecs.eyas.combustion.dao.ChimneyDao;
import com.infitecs.eyas.combustion.dao.CleanDao;
import com.infitecs.eyas.combustion.model.CalculateBurn;
import com.infitecs.eyas.combustion.model.CalculateChimney;
import com.infitecs.eyas.combustion.model.CalculateClean;
import com.infitecs.eyas.combustion.service.BurnService;
import com.infitecs.eyas.combustion.service.ChimneyService;
import com.infitecs.eyas.combustion.service.CleanService;
import com.infitecs.eyas.mill.dao.MillSelectDao;
import com.infitecs.eyas.mill.dao.PipeCalculateDao;
import com.infitecs.eyas.mill.model.MillSelect;
import com.infitecs.eyas.mill.model.PipeCalculate;
import com.infitecs.eyas.mill.service.MillSelectService;
import com.infitecs.eyas.mill.service.PipeCalculateService;
import com.infitecs.eyas.power.dao.OperateFieldDao;
import com.infitecs.eyas.power.model.OperateField;
import com.infitecs.eyas.quality.model.Element;
import com.infitecs.eyas.quality.model.Industry;
import com.infitecs.eyas.result.dao.MiddleResultDao;
import com.infitecs.eyas.result.model.MiddleResult;
import com.infitecs.eyas.boiler.service.AirGasParameterService;
import com.infitecs.eyas.expression.dao.ExpressionDao;
import com.infitecs.eyas.expression.model.Formula;
import com.infitecs.eyas.nature.dao.NatureDao;
import com.infitecs.eyas.nature.model.Nature;
import com.infitecs.eyas.runcoalbin.dao.CoalBunkerDao;
import com.infitecs.eyas.runcoalbin.model.CoalBunker;
import com.infitecs.eyas.runcoalbin.service.CoalBunkerService;
import com.infitecs.eyas.util.DoubleUtil;
import com.infitecs.eyas.util.Parameter;
import com.infitecs.eyas.util.ParametersUtil;
import fr.expression4j.core.Expression;
import fr.expression4j.core.Parameters;
import fr.expression4j.core.exception.EvalException;
import fr.expression4j.core.exception.ParsingException;
import fr.expression4j.factory.ExpressionFactory;
import org.apache.tools.ant.taskdefs.optional.Cab;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: chenkaiyu
 * Date: 15-5-24
 * Time: 下午5:48
 * To change this template use File | Settings | File Templates.
 */
@Service("AirGasParameterService")
@Transactional
public class AirGasParameterServiceImpl implements AirGasParameterService {
    @Autowired
    private AirGasParameterDao airGasParameterDao;
    @Autowired
    private NatureDao natureDao;
    @Autowired
    private ExpressionDao expressionDao;

    @Autowired
    private MiddleResultDao middleResultDao;
    @Autowired
    private EfficiencyDao efficiencyDao;
    @Autowired
    private EfficiencyService efficiencyService;
    @Autowired
    private CoalBunkerDao coalBunkerDao;
    @Autowired
    private CoalBunkerService coalBunkerService;
    @Autowired
    private BurnService burnService;
    @Autowired
    private BurnDao burnDao;
    @Autowired
    private OperateFieldDao operateFieldDao;
    @Autowired
    private CleanService cleanService;
    @Autowired
    private CleanDao cleanDao;
    @Autowired
    private ChimneyDao chimneyDao;
    @Autowired
    private ChimneyService chimneyService;
    @Autowired
    private MillSelectDao millSelectDao;
    @Autowired
    private MillSelectService millSelectService;
    @Autowired
    private PipeCalculateService pipeCalculateService;
    @Autowired
    private PipeCalculateDao pipeCalculateDao;
    @Override
    public void saveTheValueOfE31(double E31, int powerCaseId) {
        airGasParameterDao.updateE31(E31, powerCaseId);
    }

    @Override
    public void saveTheValueOfE32(double E32, int powerCaseId) {
        airGasParameterDao.updateE32(E32, powerCaseId);
    }

    @Override
    public void saveTheValueOfE28(double E28, int powerCaseId) {
        airGasParameterDao.updateE28(E28, powerCaseId);
    }

    @Override
    public void saveTheValueOfE33(double E33, int powerCaseId) {
        airGasParameterDao.updateE33(E33, powerCaseId);
    }

    @Override
    public void saveTheValueOfE34(double E34, int powerCaseId) {
        airGasParameterDao.updateE34(E34, powerCaseId);
    }

    @Override
    public void saveTheValueOfE35(double E35, int powerCaseId) {
        airGasParameterDao.updateE35(E35, powerCaseId);
    }

    @Override
    public void saveTheValueOfE42(double E42, int powerCaseId) {
        airGasParameterDao.updateE42(E42, powerCaseId);
    }

    @Override
    public void saveTheValueOfE43(double E43, int powerCaseId) {
        airGasParameterDao.updateE43(E43, powerCaseId);
    }

    @Override
    public void saveTheValueOfE44(double E44, int powerCaseId) {
        airGasParameterDao.updateE44(E44, powerCaseId);
    }

    @Override
    public void saveTheValueOfE45(double E45, int powerCaseId) {
        airGasParameterDao.updateE45(E45, powerCaseId);
    }

    @Override
    public void saveTheValueOfE46(double E46, int powerCaseId) {
        airGasParameterDao.updateE46(E46, powerCaseId);
    }

    @Override
    public void saveTheValueOfE111(int E111, int powerCaseId) {
        airGasParameterDao.updateE111(E111, powerCaseId);
    }

    @Override
    public void saveTheValueOfE50(double E50, int powerCaseId) {
        airGasParameterDao.updateE50(E50, powerCaseId);
    }

    @Override
    public AirGasParameter getAirGasParameter(int caseId) {
        return airGasParameterDao.getAirGasParameter(caseId);
    }

    @Override
    public void insertCaseId(int caseId) {
        airGasParameterDao.insertCaseId(caseId);
    }

    @Override
    public Double calculateE36(int caseId, int powerId) {
        AirGasParameter air = airGasParameterDao.getAirGasParameter(caseId);
        Nature nature = natureDao.getNatureByPowerId(powerId);
        Formula formula = expressionDao.getFormulaByName("公式25");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E31", air.getInOnceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
        airGasParameterDao.updateMIddleResult(new AirGasParameter(caseId, result, "E36"));
        return result;
    }

    @Override
    public Double calculateE37(int caseId, int powerId) {
        AirGasParameter air = airGasParameterDao.getAirGasParameter(caseId);
        Nature nature = natureDao.getNatureByPowerId(powerId);
        Formula formula = expressionDao.getFormulaByName("公式26");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E32", air.getInTwiceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
        airGasParameterDao.updateMIddleResult(new AirGasParameter(caseId, result, "E37"));
        return result;

    }

    @Override
    public Double calculateE38(int caseId, int powerId) {
        AirGasParameter air = airGasParameterDao.getAirGasParameter(caseId);
        Nature nature = natureDao.getNatureByPowerId(powerId);
        Formula formula = expressionDao.getFormulaByName("公式27");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E33", air.getOutOnceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
        airGasParameterDao.updateMIddleResult(new AirGasParameter(caseId, result, "E38"));
        return result;
    }

    @Override
    public Double calculateE39(int caseId, int powerId) {
        AirGasParameter air = airGasParameterDao.getAirGasParameter(caseId);
        Nature nature = natureDao.getNatureByPowerId(powerId);
        Formula formula = expressionDao.getFormulaByName("公式28");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E34", air.getOutTwiceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
        airGasParameterDao.updateMIddleResult(new AirGasParameter(caseId, result, "E39"));
        return result;
    }

    @Override
    public Double calculateE40(int caseId, int powerId) {
        AirGasParameter air = airGasParameterDao.getAirGasParameter(caseId);
        Nature nature = natureDao.getNatureByPowerId(powerId);
        Formula formula = expressionDao.getFormulaByName("公式29");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E35", air.getCoalInOnceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
        airGasParameterDao.updateMIddleResult(new AirGasParameter(caseId, result, "E40"));
        return result;
    }

    @Override
    public Double calculateE41(int caseId, int powerId) {
        AirGasParameter air = airGasParameterDao.getAirGasParameter(caseId);
        //MiddleResult middleResult=airGasParameterDao.getMIddleResult(caseId);
        Nature nature = natureDao.getNatureByPowerId(powerId);
        Formula formula = expressionDao.getFormulaByName("锅炉公式7");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        double e36 = middleResultDao.getMiddleResult(new MiddleResult(caseId, "E36"));
        double e40 = middleResultDao.getMiddleResult(new MiddleResult(caseId, "E40"));
        double e38 = middleResultDao.getMiddleResult(new MiddleResult(caseId, "E38"));
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E40", e40));
        params.add(new Parameter("E36", e36));
        params.add(new Parameter("E38", e38));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
//        airGasParameterDao.updateMIddleResult((new AirGasParameter(caseId, result, "E41")));
        middleResultDao.upMiddleResult(new MiddleResult(caseId, "E41", result));
        return result;
    }

    @Override
    public Double calculateE61(int caseId, int powerId) {
        AirGasParameter air = airGasParameterDao.getAirGasParameter(caseId);
        Nature nature = natureDao.getNatureByPowerId(powerId);
        Formula formula = expressionDao.getFormulaByName("锅炉公式19");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E31", air.getE40()));
        params.add(new Parameter("E42", air.getE36()));
        params.add(new Parameter("E32", air.getE38()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
        airGasParameterDao.updateMIddleResult(new AirGasParameter(caseId, result, "E61"));
        return result;
    }

    @Override
    public Double calculateE63(int caseId, int powerId) {
        AirGasParameter air = airGasParameterDao.getAirGasParameter(caseId);
        Nature nature = natureDao.getNatureByPowerId(powerId);
        Formula formula = expressionDao.getFormulaByName("锅炉公式21");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E50", air.getOutAirTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
        airGasParameterDao.updateMIddleResult(new AirGasParameter(caseId, result, "E63"));
        return result;
    }

    @Override
    public void airGasSave(AirGasParameter airGasParameter) {
        airGasSaveData(airGasParameter);
        //更新锅炉效率及燃煤量
        Efficiency oldEfficiency = efficiencyDao.getEfficiencyByPowerCaseId(airGasParameter.getPowerCaseId());
        OperateField operateField = operateFieldDao.getOperateField(airGasParameter.getPowerCaseId());
        if (oldEfficiency == null) return;
        oldEfficiency.setE52State(operateField.getE52State());
        oldEfficiency.setE89State(operateField.getE89State());
        oldEfficiency.setE90State(operateField.getE90State());
        oldEfficiency.setE92State(operateField.getE92State());
        oldEfficiency.setE93State(operateField.getE93State());
        oldEfficiency.setE94State(operateField.getE94State());
        oldEfficiency.setE95State(operateField.getE95State());
        efficiencyService.efficiencySaveData(oldEfficiency);

        //更新原煤仓
        CoalBunker oldCoalBunker = coalBunkerDao.getCoalBunker(airGasParameter.getPowerCaseId());
        //更新原煤仓信息
        if (oldCoalBunker != null) {
            oldCoalBunker.setE9State(operateField.getE9State());
            coalBunkerService.designSaveData(oldCoalBunker);
        }
        //更新燃烧
        CalculateBurn calculateBurn = burnDao.getCalculateBurnByCaseId(airGasParameter.getPowerCaseId());
        if (calculateBurn != null) {
            calculateBurn.setYyglState(operateField.getYyglState());
            calculateBurn.setE54State(operateField.getE54State());
            calculateBurn.setE88State(operateField.getE88State());
            calculateBurn.setE122State(operateField.getE122State());
            calculateBurn.setE155State(operateField.getE155State());
            calculateBurn.setE171State(operateField.getE171State());
            burnService.burnSaveData(calculateBurn);
        }
        //更新烟气净化系统
        CalculateClean calculateClean = cleanDao.getCalculateClean(airGasParameter.getPowerCaseId());
        if (calculateClean != null) {
            calculateClean.setE221State(operateField.getE221State());
            calculateClean.setE222State(operateField.getE222State());
            calculateClean.setE231State(operateField.getE231State());
            calculateClean.setE241State(operateField.getE241State());
            calculateClean.setE242State(operateField.getE242State());
            calculateClean.setE248State(operateField.getE248State());
            calculateClean.setE258State(operateField.getE258State());
            cleanService.cleanDataSave(calculateClean);
        }
        //更新烟囱出口直径计算
        CalculateChimney calculateChimney = chimneyDao.getCalculateChimney(airGasParameter.getPowerCaseId());
        if (calculateChimney != null) {
            calculateChimney.setE314State(operateField.getE314State());
            calculateChimney.setE315State(operateField.getE315State());
            calculateChimney.setE316State(operateField.getE316State());
            calculateChimney.setCaseId(operateField.getCaseId());
            chimneyService.chimneySaveData(calculateChimney);
        }

        //更新磨煤机选择
        MillSelect millSelect = millSelectDao.getMillSelect(airGasParameter.getPowerCaseId());
        if (millSelect != null) {
            millSelect.setMyglState(operateField.getMyglState());
            millSelect.setE12State(operateField.getE12State());
            millSelect.setE74State(operateField.getE74State());
            millSelect.setE75State(operateField.getE75State());
            millSelect.setModelState(operateField.getModelState());
            millSelectService.chooseDataSave(millSelect);
        }
        //更新煤粉管道计算
        PipeCalculate pipeCalculate = pipeCalculateDao.getPipeCalculate(airGasParameter.getPowerCaseId());
        if (pipeCalculate != null) {
            pipeCalculateService.pipelineDataSave(pipeCalculate);
        }
    }

    private void airGasSaveData(AirGasParameter airGasParameter) {
        AirGasParameter oldData = airGasParameterDao.getAirGasParameter(airGasParameter.getPowerCaseId());
        if (oldData == null) {
            airGasParameterDao.addAirGasParameter(airGasParameter);
        } else {
            airGasParameterDao.updateAirGasParameter(airGasParameter);
        }
    }

    @Override
    public Double calculateE36(AirGasParameter air, Nature nature) {
        Formula formula = expressionDao.getFormulaByName("公式25");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E31", air.getInOnceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public Double calculateE37(AirGasParameter air, Nature nature) {
        Formula formula = expressionDao.getFormulaByName("公式26");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E32", air.getInTwiceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public Double calculateE38(AirGasParameter air, Nature nature) {
        Formula formula = expressionDao.getFormulaByName("公式27");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E33", air.getOutOnceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }


    @Override
    public Double calculateE39(AirGasParameter air, Nature nature) {
        Formula formula = expressionDao.getFormulaByName("公式28");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E34", air.getOutTwiceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public Double calculateE40(AirGasParameter air, Nature nature) {
        Formula formula = expressionDao.getFormulaByName("公式29");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E35", air.getCoalInOnceWindTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE41(Set<Parameter> params) {
        //MiddleResult middleResult=airGasParameterDao.getMIddleResult(caseId);
        Formula formula = expressionDao.getFormulaByName("锅炉公式7");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE47(Element element) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式8");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("ME17", element.getQgrAr()));
        params.add(new Parameter("ME30", element.getSar()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE48(double e47) {
        Double result = null;
        if (e47 < 1.5) {
            result = 68.3;
        } else if (e47 >= 1.5 && e47 <= 3.5) {
            result = 8.265 * e47 + 56;
        } else {
            result = 85.00;
        }
        return result;
    }

    @Override
    public double calculateE49(AirGasParameter air, double e48) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式10");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E31", air.getInOnceWindTemperature()));
        params.add(new Parameter("E32", air.getInTwiceWindTemperature()));
        params.add(new Parameter("E42", air.getOnceWindRate()));
        params.add(new Parameter("E48", e48));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE53(Industry industry, Element element) {
        double E53;
        double E13 = element.getQnetAr();
        double E6 = industry.getAar();
        if (E13 / 420 > E6)
            E53 = 0;
        else
            E53 = 100 / E13;
        return E53;
    }

    @Override
    public double calculateE55(Element element) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式13");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("ME26", element.getCar()));
        params.add(new Parameter("ME27", element.getHar()));
        params.add(new Parameter("ME30", element.getSar()));
        params.add(new Parameter("ME28", element.getOar()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE56(Element element) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式14");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("ME26", element.getCar()));
        params.add(new Parameter("ME27", element.getHar()));
        params.add(new Parameter("ME30", element.getSar()));
        params.add(new Parameter("ME28", element.getOar()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE57(Nature nature, double e55) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式15");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE58(Nature nature, double e57) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式16");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E57", e57));
        params.add(new Parameter("ZE15", nature.getLocalDensityMoistAir()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE59(AirGasParameter air, double e58) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式17");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E58", e58));
        params.add(new Parameter("E45", air.getHearthOverOutAirCoefficient()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE61(AirGasParameter air, Nature nature) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式19");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E31", air.getE40()));
        params.add(new Parameter("E42", air.getE36()));
        params.add(new Parameter("E32", air.getE38()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
        return result;
    }

    @Override
    public double calculateE62(AirGasParameter air, double e60, double e61) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式20");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E61", e61));
        params.add(new Parameter("E60", e60));
        params.add(new Parameter("E31", air.getInOnceWindTemperature()));
        params.add(new Parameter("E32", air.getInTwiceWindTemperature()));
        params.add(new Parameter("E42", air.getOnceWindRate()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE63(AirGasParameter air, Nature nature) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式21");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E50", air.getOutAirTemperature()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        air.setResult(result);
        return result;
    }

    @Override
    public double calculateE64(Element element) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式22");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;

        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("ME26", element.getCar()));
        params.add(new Parameter("ME30", element.getSar()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE65(Element element, double e55) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式23");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("ME29", element.getNar()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE66(Industry industry, Nature nature, Element element, double e55) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式24");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("ME27", element.getHar()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        params.add(new Parameter("ME3", industry.getMar()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE67(double e64, double e65) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式25");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E64", e64));
        params.add(new Parameter("E65", e65));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE68(double e66, double e67) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式26");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E66", e66));
        params.add(new Parameter("E67", e67));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE69(AirGasParameter air, double e55, double e65) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式27");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E45", air.getHearthOverOutAirCoefficient()));
        params.add(new Parameter("E65", e65));
        params.add(new Parameter("E55", e55));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE70(AirGasParameter air, double e55) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式28");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E45", air.getHearthOverOutAirCoefficient()));
        params.add(new Parameter("E55", e55));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE71(AirGasParameter air, Nature nature, double e55, double e66) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式29");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E45", air.getHearthOverOutAirCoefficient()));
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("E66", e66));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE72(double e64, double e69, double e70) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式30");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E64", e64));
        params.add(new Parameter("E69", e69));
        params.add(new Parameter("E70", e70));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE73(double e71, double e72) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式31");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E71", e71));
        params.add(new Parameter("E72", e72));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE74(Industry industry, Nature nature, Element element, AirGasParameter air, double e55) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式32");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("E45", air.getHearthOverOutAirCoefficient()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        params.add(new Parameter("ME27", element.getHar()));
        params.add(new Parameter("ME29", element.getNar()));
        params.add(new Parameter("ME30", element.getSar()));
        params.add(new Parameter("ME28", element.getOar()));
        params.add(new Parameter("ME3", industry.getMar()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE75(AirGasParameter air, double e58, double e74) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式33");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E74", e74));
        params.add(new Parameter("E58", e58));
        params.add(new Parameter("E46", air.getAirPreheaterAirLeakageCoefficient()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE76(AirGasParameter air, Industry industry, Nature nature, double e55, double e58, double e74) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式32-1");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Double result1 = null;
        Double result2 = null;
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E46", air.getAirPreheaterAirLeakageCoefficient()));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        params.add(new Parameter("E74", e74));
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("ME6", industry.getAar()));
        Parameters parameters = ParametersUtil.getParameters(params);
        try {
            result1 = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        Formula formula1 = expressionDao.getFormulaByName("锅炉公式32-2");
        String exp1 = formula1.getParamer() + formula1.getFormulaDescription();
        Expression expression1 = null;

        try {
            expression1 = ExpressionFactory.createExpression(exp1);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params1 = new HashSet<>();
        params1.add(new Parameter("E46", air.getAirPreheaterAirLeakageCoefficient()));
        params1.add(new Parameter("E45", air.getHearthOverOutAirCoefficient()));
        params1.add(new Parameter("E74", e74));
        params1.add(new Parameter("E58", e58));
        Parameters parameters1 = ParametersUtil.getParameters(params1);
        try {
            result2 = expression1.evaluate(parameters1).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        Double result = null;
        result = Math.max(result1, result2);
        return result;
    }

    @Override
    public double calculateE60(double e58, double e76) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式18");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E58", e58));
        params.add(new Parameter("E76", e76));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE77(double e55, double e65, double e76) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式35");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("E65", e65));
        params.add(new Parameter("E76", e76));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE78(double e55, double e76) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式36");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("E76", e76));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE79(Nature nature, double e55, double e66, double e76) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式37");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("E66", e66));
        params.add(new Parameter("E76", e76));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE80(double e64, double e77, double e78) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式38");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E78", e78));
        params.add(new Parameter("E64", e64));
        params.add(new Parameter("E77", e77));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE81(double e79, double e80) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式39");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E80", e80));
        params.add(new Parameter("E79", e79));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE82(Industry industry, Nature nature, double e55, double e76) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式40");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E55", e55));
        params.add(new Parameter("E76", e76));
        params.add(new Parameter("ZE14", nature.getAnnualAverageAirMoisture()));
        params.add(new Parameter("ME6", industry.getAar()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE83(AirGasParameter air) {
        double E50 = air.getOutAirTemperature();
        Formula formula = expressionDao.getFormulaByName("锅炉公式41");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E50", E50));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE84(AirGasParameter air) {
        double E50 = air.getOutAirTemperature();
        Formula formula = expressionDao.getFormulaByName("锅炉公式42");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E50", E50));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE85(AirGasParameter air) {
        double E50 = air.getOutAirTemperature();
        Formula formula = expressionDao.getFormulaByName("锅炉公式43");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E50", E50));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE86(AirGasParameter air) {
        double E50 = air.getOutAirTemperature();
        Formula formula = expressionDao.getFormulaByName("锅炉公式44");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E50", E50));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }


    @Override
    public double calculateE87(AirGasParameter air, double e64, double e77, double e78, double e79, double e83, double e84, double e85, double e86) {
        double E50 = air.getOutAirTemperature();
        Formula formula = expressionDao.getFormulaByName("锅炉公式45");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E50", E50));
        params.add(new Parameter("E83", e83));
        params.add(new Parameter("E64", e64));
        params.add(new Parameter("E84", e84));
        params.add(new Parameter("E77", e77));
        params.add(new Parameter("E85", e85));
        params.add(new Parameter("E78", e78));
        params.add(new Parameter("E86", e86));
        params.add(new Parameter("E79", e79));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public double calculateE88(Element element, double e62, double e87) {
        double E15 = element.getQnetAr();
        Formula formula = expressionDao.getFormulaByName("锅炉公式46");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("E62", e62));
        params.add(new Parameter("E87", e87));
        params.add(new Parameter("ME15", E15));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return DoubleUtil.getInstance().get3Double(result);
    }

    @Override
    public double calculateE51(Industry industry) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式89");
        Double me10 = industry.getVdaf();
        Double result = null;
        if (me10 > 30)
            result = 2.00;
        else {
            String exp = formula.getParamer() + formula.getFormulaDescription();
            Expression expression = null;
            try {
                expression = ExpressionFactory.createExpression(exp);
            } catch (ParsingException e) {
                e.printStackTrace();
            }
            Set<Parameter> params = new HashSet<>();
            params.add(new Parameter("ME10", me10));
            Parameters parameters = ParametersUtil.getParameters(params);

            try {
                result = expression.evaluate(parameters).getRealValue();
            } catch (EvalException e) {
                e.printStackTrace();
            }
        }
        return result;
    }

    @Override
    public double calculateE52(Industry industry, Element element, double e51) {
        Formula formula = expressionDao.getFormulaByName("锅炉公式11");
        String exp = formula.getParamer() + formula.getFormulaDescription();
        Expression expression = null;
        try {
            expression = ExpressionFactory.createExpression(exp);
        } catch (ParsingException e) {
            e.printStackTrace();
        }
        Set<Parameter> params = new HashSet<>();
        params.add(new Parameter("ME6", industry.getAar()));
        params.add(new Parameter("E51", e51));
        params.add(new Parameter("ME13", element.getQnetAr()));
        Parameters parameters = ParametersUtil.getParameters(params);
        Double result = null;
        try {
            result = expression.evaluate(parameters).getRealValue();
        } catch (EvalException e) {
            e.printStackTrace();
        }
        return DoubleUtil.getInstance().get4Double(result);
    }

}
